package sort;

/**
 * 冒泡排序
 * 
 * @author 12609
 *
 */
public class BubbleSort {

	public static void sort(int args[]) {

		int len = args.length;
		for (int i = 0; i < len - 1; i++) {
			for (int j = 0; j < len - i - 1; j++) {
				if (args[j] > args[j + 1]) {
					int tmp = args[j];
					args[j] = args[j + 1];
					args[j + 1] = tmp;
				}
			}
		}
		for (int tmp : args) {
			System.out.println(tmp);
		}
	}

	public static void main(String[] args) {
		int[] list = { 2, 6, 3, 8, 4, 22, 12 };
		sort(list);
	}

}
